import request from '@/utils/request';

export const getChannelList = (deviceId: any, currentPage: number, count: number, searchSrt: string, online: string, channelType: string) => {
  return request({
    url: `/api/device/query/devices/${deviceId}/channels`,
    method: 'get',
    params: {
      page: currentPage,
      count: count,
      query: searchSrt,
      online: online,
      channelType: channelType
    }
  });
};
export const startPlay = (deviceId: any, channelId: any) => {
  return request({
    url: `/api/play/start/${deviceId}/${channelId}`,
    method: 'get'
  });
};
export const getSubChannelList = (
  deviceId: any,
  channelId: any,
  currentPage: number,
  count: number,
  searchSrt: string,
  online: string,
  channelType: string
) => {
  return request({
    url: `/api/device/query/devices/${deviceId}/channels/${channelId}/subchannels`,
    method: 'get',
    params: {
      page: currentPage,
      count: count,
      query: searchSrt,
      online: online,
      channelType: channelType
    }
  });
};
export const getTreeChannel = (deviceId: any, parentId: any, currentPage: number, count: number) => {
  return request({
    url: `/api/device/query/tree/channel/${deviceId}`,
    method: 'get',
    params: {
      parentId: parentId,
      page: currentPage,
      count: count
    }
  });
};
export const updateChannel = (deviceId: any, data: any) => {
  return request({
    url: `/api/device/query/channel/update/${deviceId}`,
    method: 'post',
    params: data
  });
};
export const updateStreamIdentification = (data: any) => {
  return request({
    url: `/api/device/query/channel/stream/identification/update/`,
    method: 'post',
    params: data
  });
};
export const stopPlay = (deviceId: any, channelId: any, isSubStream: any) => {
  return request({
    url: `/api/play/stop/${deviceId}/${channelId}`,
    method: 'get',
    params: {
      isSubStream: isSubStream
    }
  });
};

export const convertStream = (streamId: any) => {
  return request({
    url: `/api/play/convert/${streamId}`,
    method: 'post'
  });
};

export const listDeviceChannel = (query?: any) => {
  return request({
    url: '/api/device/query/list',
    method: 'get',
    params: query
  });
};

export const getDeviceChannel = (id: string | number): any => {
  return request({
    url: '/api/device/query/' + id,
    method: 'get'
  });
};
